home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 22 / AACD 22.iso / AACD / Programming / PrometheusSDK / Developer / Examples / prmscan / prmscan.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-31  |  2.1 KB  |  68 lines

  1. /* Source code of prmscan - program scanning system for PCI cards plugged   */
  2. /* into Prometheus board. It demonstrates use of prometheus.library.        */
  3.  
  4. #define __NOLIBBASE__  /* we do not want to peeking library bases */
  5.  
  6. #include <proto/exec.h>
  7. #include <proto/dos.h>
  8. #include <proto/prometheus.h>
  9.  
  10. struct Library *SysBase, *DOSBase, *PrometheusBase;
  11.  
  12. const char *VString = "$VER: prmscan 1.1 (31.3.2001) © 2001 Matay.\n";
  13.  
  14.  
  15. LONG Main (void)
  16.  {
  17.   Printf ("\nPrmscan 1.1 © 2001 Matay.\n");
  18.   Printf ("PCI cards listing:\n-------------------------------------------------\n");
  19.   if (PrometheusBase = OpenLibrary ("prometheus.library", 1))
  20.    {
  21.     APTR board = NULL;
  22.     ULONG vendor, device, revision, dclass, dsubclass, blkaddr, blksize;
  23.     ULONG romaddr, romsize;
  24.     WORD blk;
  25.  
  26.     while (board = Prm_FindBoardTags (board, TAG_END))
  27.      {
  28.       Prm_GetBoardAttrsTags(board,
  29.        PRM_Vendor, (ULONG)&vendor,
  30.        PRM_Device, (ULONG)&device,
  31.        PRM_Revision, (ULONG)&revision,
  32.        PRM_Class, (ULONG)&dclass,
  33.        PRM_SubClass, (ULONG)&dsubclass,
  34.        TAG_END);
  35.       Printf ("Vendor %04lx, device %04lx, revision %ld.\n", vendor, device,
  36.        revision);
  37.       Printf ("Device class %02lx, subclass %02lx.\n", dclass, dsubclass);
  38.       for (blk = 0; blk < 6; blk++)
  39.        {
  40.         Prm_GetBoardAttrsTags (board,
  41.          PRM_MemoryAddr0 + blk, (ULONG)&blkaddr,
  42.          PRM_MemorySize0 + blk, (ULONG)&blksize,
  43.          TAG_END);
  44.         if (blkaddr && blksize)
  45.          {
  46.           Printf ("Address range: %08lx - %08lx.\n", blkaddr, blkaddr + blksize
  47.            - 1);
  48.          }
  49.        }
  50.       Prm_GetBoardAttrsTags(board,
  51.        PRM_ROM_Address, (ULONG)&romaddr,
  52.        PRM_ROM_Size, (ULONG)&romsize,
  53.        TAG_END);
  54.       if (romaddr && romsize)
  55.        {
  56.         Printf ("%ld kB of ROM at %08lx - %08lx.\n", romsize >> 10, romaddr,
  57.          romaddr + romsize - 1);
  58.        }
  59.       Printf ("-------------------------------------------------\n");
  60.      }
  61.     Printf ("\n");
  62.     CloseLibrary (PrometheusBase);
  63.    }
  64.   else Printf ("No working Prometheus board found in the system.\n\n");
  65.   return 0;
  66.  }
  67.  
  68.